# ====================== while ==========================

x = 1
while x <= 9:
    y = 1
    while y <= x:
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
        y += 1

    x += 1
    print(' ')

print('=' * 80)

y = 9
while y > 0:
    x = 1
    while x <= y:
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
        x += 1

    y = y - 1
    print('')
print('=' * 80)

# --------------------------------------------------
x = 1
y = 1
while x <= 9:

    print(' ' * 8 * (9 - x), end='')
    while y > 0:
        print('{}*{}={:<4}'.format(y, x, x * y), end='')
        y = y - 1

    x = x + 1
    y = x
    print(' ')

print('=' * 80)


y = 9
x = 9
while y > 0:

    print(' ' * 8 * (9 - y), end='')
    while x >0:
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
        x = x - 1

    y = y - 1
    x = y
    #input()
    print('')
print('=' * 80)

input()

# ===========================for ... in====================
for x in range(1,10):
    for y in range(1,x+1):
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
    print('')
print('=' * 80)

for y in range(9,0, -1):
    for x in range(1, y+1):
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
    print('')
print('=' * 80)


# ================================================
for x in range(1,10):
    print(' ' * 8*(9 - x), end='')
    for y in range(x, 0, -1):
        # print(' '*(9-x), end='')
        print('{}*{}={:<4}'.format(y, x, x * y), end='')
    print('')
print('=' * 80)

for y in range(9,0, -1):
    print(' ' * 8 * (9 - y), end='')
    for x in range(y, 0, -1):
        print('{}*{}={:<4}'.format(x, y, x * y), end='')
    print('')
print('=' * 80)
